package com.bingbing.back.service.Impl;

import com.bingbing.back.dto.CityLocDto;
import com.bingbing.back.mapper.CityLocMapper;
import com.bingbing.back.po.CityLoc;
import com.bingbing.back.service.CityLocService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class CityLocServiceImpl implements CityLocService {
    @Resource
    private CityLocMapper cityLocMapper;

    @Override
    public List<CityLocDto> findAll() {
        List<CityLocDto> result = new ArrayList<>();
        List<CityLoc> list = cityLocMapper.showAllProvince();
        list.forEach(s->{
            String Pro = s.getProvince();
            CityLocDto x = new CityLocDto();

            x.setProvince(Pro);
            x.setCitys(cityLocMapper.findByProvince(Pro));
            result.add(x);
        });
        return result;
    }
}
